<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.sql.*"  %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>删除数据</title>
</head>
<body>

<%
String restaurant_name = request.getParameter("restaurant_name");
String customer_name = request.getParameter("customer_name");
//接收from数据
request.setCharacterEncoding("UTF-8");
String meal_name = request.getParameter("meal_name");
//连接数据库
Class.forName("org.mariadb.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mariadb://localhost:3306/mealdb?user=root&password=1230321");
Statement stmt = conn.createStatement();

//构造SQL写入数据到数据表
String sql ="delete FROM cart WHERE meal_name='"+meal_name+"'";
System.out.print("sql= "+sql);
out.print("响应行数： "+stmt.executeUpdate(sql));

stmt.close();
conn.close();

//返回列页面
out.print("修改完毕！");
response.sendRedirect("viewOrders.jsp?customer_name="+customer_name+"&restaurant_name="+restaurant_name);
%>
